var app = angular.module('crawlerApp');

app.controller('sidebarCtrl', ['$scope', '$state', 'ngDialog',
  function($scope,
    $state, ngDialog) {

    // 新建
    $scope.addItems = function(type) {
      $scope.type = type;
      var dialog = ngDialog.openConfirm({
        template: 'src/sidebar/tmpl/add-items.html',
        // plain: true,
        resolve: {
          addType: function addType() {
            return type
          }
        },
        controller: ['$scope', 'addType', function(scope, type) {
          scope.type = type;
        }]
      });
      dialog.then(function(res) {
        // console.log(res, 'data');
        if ($scope.type == 'group') {
          $state.go('group', {
            id: 3
          });
        } else if ($scope.type == 'project') {
          $state.go('project', {
            id: 3
          });
        } else if ($scope.type == 'set') {
          $state.go('set', {
            id: 3
          });
        }
      }, function(rea) {
        console.log('cancel', rea);
      });
    };
  }
]);
